import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/hello")
public class HelloServlet extends HttpServlet {

    //doGet 处理一个HTTP请求
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //req代表一个http请求    resp代表http相应

//        super.doGet(req,resp); //自定义doGet方法时需要注释这一行

        //让服务器在自己的控制台里打印

        System.out.println("Hello World");

        //在页面上打印Hello World    使用getwriter（）方法返回一个writer对象（字符流对象）
        //此处writer往body标签里面写东西
        resp.getWriter().write("Hello World"+System.currentTimeMillis());
//        while (true){
//            try {
//                Thread.currentThread().sleep(1000);
//
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//        }

//        resp.setHeader("Refresh","1");



    }





}
